#! /run/current-system/sw/bin/bash
#! /bin/bash

kdialog --title "XMonad" --icon=/home/sny/.icons/xmonad.png --yesno "Switch to XMonad?"

if [ $? -eq 0 ]; then
    qdbus org.kde.kglobalaccel /kglobalaccel blockGlobalShortcuts true
    sleep 1s
    xmonad --replace
    sleep 1s
    kill -9 $(pidof kwin_x11)
    sleep 1s
    xmonad --restart
else
    exit
fi

kill -9 $(ps aux | grep -i xmonad_replace_kwin.sh | head -1 | cut -d ' ' -f 8)
